home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbfaqr01.zip
/
KEYCODE.DOC
< prev
next >
Wrap
Text File
|
1992-03-08
|
2KB
|
57 lines
===========================================================================
BBS: « SMARTalec Toronto (416) 253-5900 »
Date: 02-24-92 (02:07) Number: 3015
From: DAVE NAVARRO Refer#: NONE
To: MARK THOMPSON Recvd: NO
Subj: ZF = Z Flag? Conf: (135) R-QBasic
---------------------------------------------------------------------------
Here is some PowerBASIC code to read a key from the keyboard (101 key
aware).
The "zero" flag us actually bit 7 of the "flags" register..
'GetKey - Check if a key is pending and return the key to your program
' Extended keyboard aware.
FUNCTION GetKey$ PUBLIC
REG 1, &HC000 'BIOS get configuration
CALL INTERRUPT &H15
DEF SEG=REG(9)
ExKy%=(PEEK(REG(2)+5) AND 16)=16 'returns true if extended KB
DEF SEG
IF ExKy% THEN Extended
REG 1, &H0100 'regular BIOS check key routine
CALL INTERRUPT &H16
IF (REG(0) AND 64)=64 THEN EXIT FUNCTION 'if zero flag then no key
REG 1, &H0000 'regular BIOS read key routine
CALL INTERRUPT &H16
K1%=REG(1) AND &HFF 'ASCII code in AL
K2%=(REG(1)\2 AND &H7FFF)\128 'scan code in AH
IF K1%=0 THEN
GetKey$=CHR$(0,K2%)
ELSE
GetKey$=CHR$(K1%)
END IF
EXIT FUNCTION
Extended:
REG 1, &H1100
CALL INTERRUPT &H16
IF (REG(0) AND 64)=64 THEN EXIT FUNCTION
REG 1, &H1000
CALL INTERRUPT &H16
K1%=REG(1) AND &HFF
K2%=(REG(1)\2 AND &H7FFF)\128
IF K1%=0 THEN
GetKey$=CHR$(0,K2%)
ELSEIF K1%=224 AND K2%>0 THEN
GetKey$=CHR$(0,K2%)
ELSE
GetKey$=CHR$(K1%)
END IF
END FUNCTION
---
■ OLX 2.1 ■ τh¡$ τåg£¡ⁿè mªδë ƒΓφm ΓΣç¥ç£ëδ Å$ç¡¡ çhåΓá¢τΣΓ$
PCRelay:ICEBOX -> #665 RelayNet (tm)
4.10 ╘═>THE ICEBOX BBS■718.793.8548■New York■<ASP>